<?php
/**
 * The activate file of *** plugin.
 *
 * @copyright   Copyright 2013-2015 黄小标 (Xiaobiao Studio,Chongqing. )
 * @license     
 * @author      Xiaobiao Huang <huangxb0512@gmail.com>
 * @package     mailto
 * @version     $Id: mailto.html.php 02:15:24 huangxb0512@gmail.com 
 * @link        
 */
?>
<?php
js::set('userList', array_keys($mailtolist));
js::set('userListValue', array_values($mailtolist));

echo <<<EOT
<script language="javascript">
for (x in userList)
{
  userList[x] = userList[x] + "";
}

$(document).ready(function(){
  $(".a-center > #submit").click(function(){
    var mailto = $("#mailto").val().split(",");
		if(!Array.indexOf)
		{
			Array.prototype.indexOf = function(obj)
		 	{
		 		for(var i=0; i<this.length; i++)
		 		{
		 			if(this[i]==obj)
		 			{
		 				return i;
		 			} 
		    }
		    return -1;
		  } 
		}
		var userListTemp = [];
		for (i = 0; i < mailto.length-1; i++)
		{
			var pos = userList.indexOf(mailto[i].trim());
			userListTemp[i] = userListValue[pos];
		}
		userList = userListTemp;
		document.getElementById("mailto").value = userList;
  }); 
  
  $("#titlebar > div > #submit").click(function(){
    var mailto = $("#mailto").val().split(",");
		if(!Array.indexOf)
		{
			Array.prototype.indexOf = function(obj)
		 	{
		 		for(var i=0; i<this.length; i++)
		 		{
		 			if(this[i]==obj)
		 			{
		 				return i;
		 			} 
		    }
		    return -1;
		  } 
		}
		var userListTemp = [];
		for (i = 0; i < mailto.length-1; i++)
		{
			var pos = userList.indexOf(mailto[i].trim());
			userListTemp[i] = userListValue[pos];
		}
		userList = userListTemp;
		document.getElementById("mailto").value = userList;
  });
  
});
</script>
EOT;

?>
